# -*- coding: utf-8 -*-
# @Time    : 2018/7/21 21:34
# @Author  : Tianchiyue
# @File    : api_test.py
# @Software: PyCharm Community
"""
局域网测试：
- 虚拟机ubuntu  nc -v -w 10 -z 192.168.1.140 7700  成功即显示succeed
- 在windows中防火墙 入站规则和出站规则，内部可以访问，外部不可以。 可能未重启？ 但是netstat -na 中显示被监听，Telnet 可以测试端口。 关闭公用网络防火墙可以用
- nginx gunicorn 部署网站
"""
import requests
from PIL import Image


headers = {'Accept': 'image/png'}

s1 = """
their application to Natural Language Processing (NLP) was less impressive at first, but has now proven to make significant contributions, yielding state-of-the-art results for some common NLP tasks. Named entity recognition (NER), part of speech (POS) tagging or sentiment analysis are some of the problems where neural network models have outperformed traditional approaches. The progress in machine translation is perhaps the most remarkable among all.

In this article I will go through some recent advancements for NLP that rely on DL techniques. I do not pretend to be exhaustive: it would simply be impossible given the vast amount of scientific papers, frameworks and tools available. I just want to share with you some of the works that I liked the most. I think the last months have been great for our field. The use of DL in NLP keeps widening, yielding amazing results in some cases, and all signs point to the fact that this trend will not stop.

From training word2vec to using pre-trained models"""

post_data = [s1]
data = requests.post("http://192.168.1.140:7700/tianchi_yue/sentiment_analysis/1.0.0/wordcloud", json=post_data)
# print((data.content))
with open('test_img.png','wb')as f:
    f.write(data.content)
# import socket
#
#
# port_number = [7700]
#
# for index in port_number:
#     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#     result = sock.connect_ex(('192.168.1.140', index))
#     if result == 0:
#         print("Port %d is open" % index)
#     else:
#         print(result)
#         print("Port %d is not open" % index)
#     sock.close()
